package org.kealinghornets.jchuah.myapplication;

import android.app.Activity;
import android.os.Bundle;
import android.util.Log;
import android.view.Menu;
import android.view.MenuItem;
import android.view.MotionEvent;
import android.view.View;
import android.view.animation.Animation;
import android.view.animation.AnimationUtils;
import android.widget.AnalogClock;
import android.widget.Toast;
import android.widget.ViewSwitcher;

public class MyActivity2 extends Activity {int numCleared = 0 ;
    public void onClockButttonPush( final View viewThatwasPushed) {
        Animation fade_out_animation = AnimationUtils.loadAnimation(this, R.anim.anim);
        fade_out_animation.setAnimationListener(new Animation.AnimationListener() {
            @Override
            public void onAnimationStart(Animation animation) {
                viewThatwasPushed.setEnabled(false);
            }

            @Override
            public void onAnimationEnd(Animation animation) {
                viewThatwasPushed.setEnabled(true);
                viewThatwasPushed.setAlpha(0);
                viewThatwasPushed.clearAnimation();

            }

            @Override
            public void onAnimationRepeat(Animation animation) {


            }
        });

        Log.d("@+id/Clock01", "2");
        Toast.makeText(this, "You're stranded on an island.Choose Black or White",Toast.LENGTH_SHORT).show();
        Log.d("@+id/Clock02", "3");
        Toast.makeText(this,"You are dead. Restart",Toast.LENGTH_SHORT).show();
        Log.d("@=id/Clock03", "4");
        Toast.makeText(this,"You were trampled by a wild Rhinoceros...You're dead, Restart",Toast.LENGTH_SHORT).show();
        Log.d("@+id?Clock10", "5");
        Toast.makeText(this,"You are found by a crew of pirates. Choose Black or White ",Toast.LENGTH_SHORT).show();
        Log.d("@+id/Clock11", "6");
        Toast.makeText(this,"You find a coconut, Choose Black or White",Toast.LENGTH_SHORT).show();
        Log.d("@+id/Clock12", "7");
        Toast.makeText(this,"You eat a poisonous mango, You have 5 minutes to live, Choose Black or White",Toast.LENGTH_SHORT).show();
        Log.d("@+is/Clock13", "8");
        Toast.makeText(this,"You were killed by a dolphinsteamrollernado. Restart",Toast.LENGTH_SHORT).show();
        Log.d("@+id/Clock20", "9");
        Toast.makeText(this,"You find a water bottle and duct tape, Choose Black or White",Toast.LENGTH_SHORT).show();
        Log.d("@+is/Clock21", "10");
        Toast.makeText(this,"You decide to take a dive in the ocean, Choose Black or White",Toast.LENGTH_SHORT).show();
        Log.d("@+id/Clock22", "11");
        Toast.makeText(this,"You then realize that the ocean was filled with dolphinsteamrollernados, You died. Restart",Toast.LENGTH_SHORT).show();
        Log.d("@+is/Clock23", "12");
        Toast.makeText(this,"You start hallucinating about the dolphinsteamrollernados, Choose Black or White ",Toast.LENGTH_SHORT).show();
        Log.d("@+id/Clock30", "13");
        Toast.makeText(this,"You find a piece of toast with a burnmark that looks like Shrek, Choose Black or White",Toast.LENGTH_SHORT).show();
        Log.d("@+id/Clock31", "14");
        Toast.makeText(this,"You are knocked by a wild pokemanz, fortunately it's a weak one, Choose Black or White ",Toast.LENGTH_SHORT).show();
        Log.d("@+id/Clock32", "15");
        Toast.makeText(this,"You have found the 7 dragon balls. You win",Toast.LENGTH_SHORT).show();
        Log.d("@+id/Clock33", "16");
        Toast.makeText(this,"You make friends with the pirate captain that is secretly Shrek. Choose Black or White",Toast.LENGTH_SHORT).show();
        Log.d("@+id/Clock40", "17");
        Toast.makeText(this,"You win",Toast.LENGTH_SHORT).show();
        Log.d("@+id/Clock41", "18");
        Toast.makeText(this,"You died of starvation",Toast.LENGTH_SHORT).show();
        Log.d("@+id/Clock42", "19");
        Toast.makeText(this,"You find a man, you kill him and take his boat. You win",Toast.LENGTH_SHORT).show();
        Log.d("@+id/Clock43","20");
        Toast.makeText(this,"You become one with the dolphinsteamrollernados and live among your people. You win",Toast.LENGTH_SHORT).show();



        if (viewThatwasPushed.getAlpha() == 1) {
            viewThatwasPushed.startAnimation(AnimationUtils.loadAnimation(this, R.anim.anim));
            numCleared = numCleared + 1;
        } else {
            viewThatwasPushed.setAlpha(1);
            numCleared = numCleared - 1;
        }

        String clockName = getResources().getResourceEntryName(viewThatwasPushed.getId());
        int clockRow = Integer.parseInt(clockName.charAt(5) + "");
        int clockColumn = Integer.parseInt(clockName.charAt(6) + "");
        Log.d("clock", "row:" + clockRow + "column:" + clockColumn);

        int getRow = 3;
        int getColumn = 2;
        View otherClock = ((View) viewThatwasPushed.getParent()).findViewById(getResources().getIdentifier("clock" + getRow
                + getColumn, "id", getPackageName()));

        if (numCleared == 10) {

        }

    }






   @Override
    public boolean onTouchEvent(MotionEvent event) {
        return super.onTouchEvent(event);
    }

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_my_activity2);
    }



    @Override
    public boolean onCreateOptionsMenu(Menu menu){
        // Inflate the menu; this adds items to the action bar if it is present.
        getMenuInflater().inflate(R.menu.my_activity2, menu);
        return true;
    }

    @Override
    public boolean onOptionsItemSelected(MenuItem item) {
        // Handle action bar item clicks here. The action bar will
        // automatically handle clicks on the Home/Up button, so long
        // as you specify a parent activity in AndroidManifest.xml.
        int id = item.getItemId();
        if (id == R.id.action_settings) {
            return true;
        }
        return super.onOptionsItemSelected(item);
    }
}
